# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=pipewire
pkgver=0.3.6
pkgrel=0
pkgdesc="Multimedia processing graphs"
url="https://pipewire.org/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="meson alsa-lib-dev libx11-dev sdl2-dev ffmpeg-dev eudev-dev dbus-dev
	glib-dev gstreamer-dev gst-plugins-base-dev sbc-dev doxygen xmltoman graphviz
	bluez-dev jack-dev vulkan-loader-dev pulseaudio-dev"
options="!check" # no tests
subpackages="$pkgname-dev $pkgname-doc $pkgname-pulse $pkgname-jack"
source="$pkgname-$pkgver.tar.gz::https://github.com/PipeWire/pipewire/archive/$pkgver.tar.gz
	fix-s390x.patch
	"

build() {
	abuild-meson \
		-Ddocs=true \
		-Dman=true \
		-Dgstreamer=true \
		-Dexamples=true \
		-Dffmpeg=true \
		-Dsystemd=false \
		. output
	ninja -C output
}

package() {
	DESTDIR="$pkgdir" ninja -C output install
}

pulse() {
	pkgdesc="Pulseaudio support for pipewire"
	mkdir -p "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}"
	mkdir -p "$subpkgdir/usr/bin"
	mv "$pkgdir/usr/lib/$pkgname-${pkgver:0:3}/pulse" \
	   "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}/"
	mv "$pkgdir/usr/bin/pw-pulse" "$subpkgdir/usr/bin/"
}

jack() {
	pkgdesc="JACK support for pipewire"
	mkdir -p "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}"
	mkdir -p "$subpkgdir/usr/bin"
	mv "$pkgdir/usr/lib/$pkgname-${pkgver:0:3}/jack" \
	   "$subpkgdir/usr/lib/$pkgname-${pkgver:0:3}/"
	mv "$pkgdir/usr/bin/pw-jack" "$subpkgdir/usr/bin/"
}

sha512sums="a8d67bb6135432705d6de026074325f0cae7f01e3fe0b65fa7dafb128e5984ce126f8b4635bfbd9746777514df6f0880a78149fd007c7c1432ac29f95655ddcc  pipewire-0.3.6.tar.gz
576a6fbb7d457bda70822a175a188b6f9dbf3b5cf9efa660e458f6d54ff6b88376821164534ec073f20b929d81c2232783f63612fc9ec5803bfe23356449f314  fix-s390x.patch"
